<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/template/template_layout_lrt.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<style>
.ui-button, .ui-button span, button.ui-button.ui-state-default span,
	.ui-button.ui-state-default span {
	font-weight: normal
}

.ui-panelgrid {
	width: 95%;
	margin: 10px;
}

.ui-rowgroup-header {
	text-align: left !important;
} 


.ui-tree .ui-tree-container {
    margin: 0;
    padding: 0px;
    width: 390px;
    white-space: nowrap;
    overflow: auto;
}

</style>
	</ui:define>
	<ui:define name="top-box-tools">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button"
				styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button"
				styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<h:form id="btnForm">
			<p:growl id="msgs" showDetail="true" />
			<p:toolbar id="btnBar">

				<!--<p:toolbar id="btnBar"  rendered="#{s:hasPermission(session,'xtsz_xtqx_zzjg_xjbm') or
			s:hasPermission(session,'xtsz_xtqx_zzjg_xzyg') or 
			s:hasPermission(session,'xtsz_xtqx_zzjg_bjbm') or 
			s:hasPermission(session,'xtsz_xtqx_zzjg_bjyg') or 
			s:hasPermission(session,'xtsz_xtqx_zzjg_sc')}"> -->


				<f:facet name="left">
					<p:commandButton icon="fa fa-plus" value="新建" id="createBtn"
						style="margin-right:10px" oncomplete="PF('createDialog').show()"
						update=":createForm btnForm:msgs"
						rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_pjbzgl_xj')}"
						disabled="#{assessmentStandardLibController.selected != null and assessmentStandardLibController.selected.itemType.value == 'INSPECTIONCRITERION'}"
						actionListener="#{assessmentStandardLibController.preCreate()}" />
					<p:commandButton icon="fa fa-pencil" value="编辑" id="editBtn"
						style="margin-right:10px"
						disabled="#{assessmentStandardLibController.selected == null}"
						rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_pjbzgl_bj')}"
						update=":createForm btnForm:msgs" oncomplete="PF('createDialog').show()"
						actionListener="#{assessmentStandardLibController.preEdit()}" />
					<p:commandButton icon="fa fa-trash-o" value="删除"
						rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_pjbzgl_sc')}"
						style="margin-right:10px"
						disabled="#{assessmentStandardLibController.selected == null}"
						update=":leftForm:tree :rightForm:plist btnForm:msgs"
						actionListener="#{assessmentStandardLibController.delete()}">
						<p:confirm header="提示" message="该记录下的所有记录都将被删除，确定删除吗?" icon="ui-icon-alert" />
					</p:commandButton>
				</f:facet>
			</p:toolbar>
		</h:form>
		<h:form id="deleteConfirmForm">
			<p:dialog id="deleteConfirmDialog" widgetVar="deleteConfirmDialog" modal="true" header="提示" width="390"
				height="150" closable="true">
	             	该标准已被模板引用，确认删除吗？<br />
				<br />
				<p:commandButton value="确定" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"
					oncomplete="PF('deleteConfirmDialog').hide();" update=":leftForm:tree :rightForm:plist btnForm:msgs"
					actionListener="#{assessmentStandardLibController.deleteTemplateItem()}" />
				<p:commandButton value="取消" styleClass="ui-confirmdialog-no" icon="ui-icon-close"
					oncomplete="PF('deleteConfirmDialog').hide()"/>
			</p:dialog>
		</h:form>
	</ui:define>
	<ui:define name="left-box-title" style="border:0">
		标准检查项目
	</ui:define>
	<ui:define name="left-box-body">
		<h:form id="leftForm">
			<p:panel style="border:0;width:98%">
				<p:tree value="#{assessmentStandardLibController.treeRoot}" var="node"
					dynamic="true" id="tree" widgetVar="tree" animate="true" style="border:0"
					selection="#{assessmentStandardLibController.selectedNode}" selectionMode="single" >
					<p:ajax event="expand" update="tree" listener="#{assessmentStandardLibController.onNodeExpand}" />
					<p:ajax event="select" listener="#{assessmentStandardLibController.onNodeSelect}"
						update="btnForm rightForm createForm" />
					<!-- 当前版本或者历史版本 -->
					<p:treeNode type="type" icon="fa fa-home">
						<h:outputText value="#{node}" />
					</p:treeNode>
					<!-- 检查作业表单 -->
					<p:treeNode type="ROOTNAME" >
						<h:outputText value="#{node.content}" />
					</p:treeNode>
					<!-- 评价分作业类 -->
					<p:treeNode type="INSPECTIONPROJECT" >
						<h:outputText value="#{node.content}" />
					</p:treeNode>
					<!-- 评价项目 -->
					<p:treeNode type="INSPECTIONITME" >
						<h:outputText value="#{node.content}" />
					</p:treeNode>
					<!-- 检查要素及要求 -->
					<p:treeNode type="INSPECTIONREQUIREMENT" >
						<h:outputText value="#{node.content}" />
					</p:treeNode>
					<!-- 评分标准 -->
					<p:treeNode type="INSPECTIONCRITERION" >
						<h:outputText value="#{node.content}" />
					</p:treeNode>
				</p:tree>
			</p:panel>
		</h:form>
	</ui:define>
	<ui:define name="right-box-title">
		标准项目列表
	</ui:define>
	<ui:define name="right-box-body">
		<h:form id="rightForm">
			<!-- 
			repeat 方式实现
			<p:panel id="plist">
				<p:outputLabel style="">#{assessmentStandardLibController.rootItem.name}</p:outputLabel>
			<p:repeat value="#{assessmentStandardLibController.selectLists}" var="project">
				<s:dataTable var="item" id="plist1"
					value="#{project.items}"
					selection="#{assessmentStandardLibController.selectedItem}"
					selectionMode="single" rowKey="#{item.id}" sortBy="#{item.id}"
					widgetVar="plist1" emptyMessage="无记录" style="text-align:center">
					<f:facet name="header">
						<h:outputText  value="#{project.projectNo}  #{project.projectName}" />
					</f:facet>
					<s:column headerText="序号" id="itemNo" groupRow="true"
						style="width:5%">
						<h:outputText value="#{item.itemNo}" />
					</s:column>
					<s:column headerText="评价项目" groupRow="true" 
						style="width:10%">
						<h:outputText value="#{item.itemName}" />
					</s:column>
					<s:column headerText="序号" groupRow="true" 
						style="width:5%">
						<h:outputText value="#{item.inspectionNo}" />
					</s:column>
					<s:column headerText="检查要素及要求" groupRow="true"
						 style="width:10%">
						<h:outputText value="#{item.inspectionName}" />
					</s:column>
					<s:column headerText="评分标准" style="width:15%">
						<h:outputText value="#{item.scoreNo}.#{item.scoreName}" />
					</s:column>
					<s:column headerText="检查参照依据" groupRow="true" 
						style="width:20%">
						<h:outputText value="#{item.docName}" />
					</s:column>
				</s:dataTable>
			</p:repeat>
			</p:panel> -->
			<s:dataTable id="plist" value="#{assessmentStandardLibController.selectLists}"
				var="item" sortBy="#{item.projectOrder}" emptyMessage="无记录" style="text-align:center" >
				<f:facet name="header">
					<h:outputText value="#{assessmentStandardLibController.rootItem.content}" />
				</f:facet>
				<p:headerRow>
					<p:column colspan="4">
						<h:outputText value="#{item.projectNo}、#{item.projectName}" />
					</p:column>
				</p:headerRow>
				<s:column headerText="评价项目" groupRow="true" 
					style="width:8%">
					<h:outputText value="#{item.itemNo}.#{item.itemName}" />
				</s:column>
				<s:column headerText="检查要素及要求" groupRow="true" 
					style="width:26%;text-align:left">
					<h:outputText value="#{item.inspectionNo}.#{item.inspectionName}" />
				</s:column>
				<s:column headerText="评分标准" groupRow="true" style="width:26%;text-align:left">
					<h:outputText value="#{item.scoreNo}.#{item.scoreName}" />
				</s:column>
				<s:column headerText="检查参照依据" groupRow="true" style="width:15%">
					<h:outputText rendered="#{item.documents.size()==0}" value=" " />
					<p:rowExpansion rendered="#{item.documents.size()>0}">
						<p:repeat value="#{item.documents}" var="doc" >
							<div class="row" style="float:left;width:85%;padding-left: 10px;" id="docDiv">
								<p:commandLink value="#{doc}" style="text-decoration:underline;" update=":btnForm:msgs"
									title="点击查看详情" actionListener="#{assessmentStandardLibController.getDocumentContent(doc)}" />
							</div>
						</p:repeat>
					</p:rowExpansion>
				</s:column>
			</s:dataTable>
		</h:form>
		<p:dialog widgetVar="createDialog" id="createDialog" header="标准检查项目信息"
			closable="true" resizable="false" draggable="false" modal="true" width="900" height="600">
			<h:form id="createForm">
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton value="保存" icon="ui-icon-disk"
							update=":leftForm:tree :btnForm:btnBar :btnForm:msgs :rightForm:plist :btnForm:editBtn"
							oncomplete="PF('createDialog').hide()" style="margin-left:10px" 
							actionListener="#{assessmentStandardLibController.save()}" />
						<p:commandButton icon="ui-icon-cancel" value="取消" type="button" onclick="PF('createDialog').hide()" />
					</f:facet>
				</p:toolbar>
				<p:outputPanel style="text-align:center;width:100%;" id="panel">
					<p:panelGrid style="width:100%;text-align:center">
						<p:row rendered="#{assessmentStandardLibController.selectedNodeType=='ROOTNAME'}">
							<p:column>
								<h:outputText value="类型:" />
							</p:column>
							<p:column>
								<h:selectOneMenu style="width:160px; height:30px" value="#{assessmentStandardLibController.current.stationType}">
									<f:selectItems value="#{assessmentStandardLibController.subStationTypes}" 
										var="item" itemLabel="#{item.label}" itemValue="#{item}"/>
								</h:selectOneMenu>
							</p:column>
						</p:row>
						<p:row rendered="#{assessmentStandardLibController.selectedNodeType=='ROOTNAME'}">
							<p:column>
								<h:outputText value="是否为当前版本:" />
							</p:column>
							<p:column>
								<p:selectBooleanButton value="#{assessmentStandardLibController.current.available}" onLabel="是" offLabel="否" style="width:60px" />
							</p:column>
						</p:row>
						<p:row rendered="#{assessmentStandardLibController.selectedNodeType!='ROOTNAME'}">
							<p:column>
								<h:outputText value="编号:" />
							</p:column>
							<p:column>
								<p:inputText value="#{assessmentStandardLibController.current.nodeNo}" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:outputText value="显示顺序:" />
							</p:column>
							<p:column>
								<p:inputNumber value="#{assessmentStandardLibController.current.nodeOrder}" minValue="1" decimalPlaces="0"/>
							</p:column>
						</p:row>
						<p:row rendered="#{assessmentStandardLibController.selectedNodeType=='INSPECTIONCRITERION'}">
							<p:column>
								<h:outputText value="扣分标准:" />
							</p:column>
							<p:column>
								<p:inputNumber value="#{assessmentStandardLibController.current.deductionCriteria}"/>
								<div style="color:red;">注：扣分请填正值，加分请填负值</div>
<!-- 							<p:inputNumber value="#{assessmentStandardLibController.current.deductionCriteria}" id="focus" title="扣分请填负值，加分请填写正值" />
								<p:tooltip id="toolTipFocus" for="focus" showEvent="focus" hideEvent="blur" /> -->
							</p:column>
						</p:row>
						<p:row rendered="#{assessmentStandardLibController.selectedNodeType=='INSPECTIONCRITERION' or assessmentStandardLibController.selectedNodeType=='INSPECTIONREQUIREMENT' or assessmentStandardLibController.selectedNodeType=='INSPECTIONITME'}">
							<p:column>
								<h:outputText value="扣分上限:" />
							</p:column>
							<p:column>
								<p:inputNumber value="#{assessmentStandardLibController.current.deductionCeiling}" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:outputText value="更新时间:" />
							</p:column>
							<p:column>
								<p:calendar navigator="true" pattern="yyyy-MM-dd HH:mm:ss"
									value="#{assessmentStandardLibController.current.updateTime}" />
							</p:column>
						</p:row>
						<p:row rendered="#{assessmentStandardLibController.selectedNodeType == 'INSPECTIONCRITERION' or assessmentStandardLibController.selectedNodeType == 'INSPECTIONREQUIREMENT'}">
							<p:column colspan="2">
								<div style="margin-top:5px;margin-bottom:5px">
									<h:outputText value="风险等级为" />
									<h:selectOneMenu value="#{assessmentStandardLibController.current.riskLevel}" style="height:28px;width:80px;margin-right:5px;margin-left:5px">
										<f:selectItem itemValue="" itemLabel="" />
										<f:selectItems value="#{assessmentStandardLibController.riskLevels}" />
									</h:selectOneMenu>
									<h:outputText value="，当扣分大于等于" />
									<p:inputNumber value="#{assessmentStandardLibController.current.riskLevelCondition}" size="8" style="margin-right:5px;margin-left:5px"/>
									<h:outputText value="分时，风险等级变为" />
									<h:selectOneMenu value="#{assessmentStandardLibController.current.riskLevelRefer}" style="height:28px;width:80px;margin-right:5px;margin-left:5px">
										<f:selectItem itemValue="" itemLabel="" />
										<f:selectItems value="#{assessmentStandardLibController.riskLevels}" />
									</h:selectOneMenu>
								</div>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:outputText value="内容" />
							</p:column>
							<p:column>
								<h:inputTextarea value="#{assessmentStandardLibController.current.content}" style="width: 90%" rows="5" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<h:outputText value="备注:" />
							</p:column>
							<p:column>
								<h:inputTextarea value="#{assessmentStandardLibController.current.remaker}" style="width: 90%" rows="3" />
							</p:column>
						</p:row>
						<p:row rendered="#{assessmentStandardLibController.selectedNodeType=='INSPECTIONCRITERION' or assessmentStandardLibController.selectedNodeType=='INSPECTIONREQUIREMENT' or assessmentStandardLibController.selectedNodeType=='INSPECTIONITME'}">
							<p:column>
								<h:outputText value="参考文档:" />
							</p:column>
							
							<p:column style="text-align:left" >
								<p:rowExpansion>
									<p:repeat value="#{assessmentStandardLibController.documents}" var="doc" >
										<div class="row" style="width:85%;padding-left: 10px;" id="docDiv">
											<h:outputText value="#{doc.name}" />
											<p:commandLink title="删除" style="margin-right:5px;float:left;"
												styleClass="ui-icon ui-icon-trash" update="createForm:panel"
												actionListener="#{assessmentStandardLibController.removeDocument(doc)}" >
												<p:confirm header="提示" message="确定移除该参考文档吗?" icon="ui-icon-alert" />
											</p:commandLink>
										</div>
									</p:repeat>
									<p:commandButton style="float:right" value="选择文档" actionListener="#{assessmentStandardLibController.openReferenceDocumentsDialog()}">
										<p:ajax event="dialogReturn"  listener="#{assessmentStandardLibController.onReferenceDocumentsChosen}" update="createForm:panel" />
									</p:commandButton>
								</p:rowExpansion>
							</p:column>
						</p:row>
					</p:panelGrid>
				</p:outputPanel>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>